.miku-button {
  position: relative;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  overflow: hidden;
  background: transparent;
  cursor: pointer;
  transform: translateZ(0);
  isolation: isolate;
  /* 防止边框缺口 */
  background-clip: padding-box;
  -webkit-background-clip: padding-box;
}

/* 修复边框缺口的关键 - 使用双层伪元素确保边框完整 */
.miku-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, 
    #39C5BB 0%, 
    #00FFFF 25%, 
    #39C5BB 50%, 
    #00FFFF 75%, 
    #39C5BB 100%);
  background-size: 400% 400%;
  animation: gradientShift 3s ease infinite;
  z-index: 1;
  /* 确保边框完整 */
  padding: 1px;
  -webkit-mask: 
    linear-gradient(#fff 0 0) content-box, 
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: 
    linear-gradient(#fff 0 0) content-box, 
    linear-gradient(#fff 0 0);
  mask-composite: exclude;
}

/* 使用 after 伪元素作为内层遮罩，确保边框完整 */
.miku-button::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  right: 2px;
  bottom: 2px;
  border-radius: 10px;
  background: var(--button-bg, linear-gradient(135deg, rgba(57, 197, 187, 0.9) 0%, rgba(0, 255, 255, 0.8) 100%));
  z-index: 1;
  transition: all 0.3s ease;
}

/* 主要样式变体 - 深色主题 */
.miku-button--primary {
  --button-bg: linear-gradient(135deg, rgba(57, 197, 187, 0.95) 0%, rgba(0, 150, 150, 0.9) 100%);
  --button-color: white;
  --button-shadow: 0 4px 20px rgba(57, 197, 187, 0.5);
  --button-glow: rgba(57, 197, 187, 0.6);
}

.miku-button--primary .ant-btn {
  background: transparent !important;
  color: var(--button-color);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  border: none;
  position: relative;
  z-index: 2;
}

/* 次要样式变体 - 浅色主题 */
.miku-button--secondary {
  --button-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(240, 250, 250, 0.95) 100%);
  --button-color: #39C5BB;
  --button-shadow: 0 4px 20px rgba(57, 197, 187, 0.3);
  --button-glow: rgba(57, 197, 187, 0.3);
}

.miku-button--secondary::before {
  background: linear-gradient(135deg, 
    #39C5BB 0%, 
    #80E0E0 25%, 
    #39C5BB 50%, 
    #80E0E0 75%, 
    #39C5BB 100%);
}

.miku-button--secondary .ant-btn {
  background: transparent !important;
  color: var(--button-color);
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
  border: none;
  position: relative;
  z-index: 2;
}

/* 发光样式变体 - 半透明发光效果 */
.miku-button--glow {
  --button-bg: linear-gradient(135deg, rgba(57, 197, 187, 0.3) 0%, rgba(0, 255, 255, 0.2) 100%);
  --button-color: white;
  --button-shadow: 0 0 30px rgba(57, 197, 187, 0.8);
  --button-glow: rgba(57, 197, 187, 0.8);
}

.miku-button--glow::before {
  background: linear-gradient(135deg, 
    #39C5BB 0%, 
    #00FFFF 20%, 
    #39C5BB 40%, 
    #00FFFF 60%, 
    #39C5BB 80%, 
    #00FFFF 100%);
  animation: gradientShift 2s ease infinite;
  filter: blur(1px);
}

.miku-button--glow::after {
  background: var(--button-bg);
  backdrop-filter: blur(10px);
}

.miku-button--glow .ant-btn {
  background: transparent !important;
  color: var(--button-color);
  text-shadow: 0 0 10px rgba(57, 197, 187, 0.8);
  border: none;
  position: relative;
  z-index: 2;
  animation: textGlow 2s ease-in-out infinite alternate;
}

/* 尺寸变体 - 加大区分度 */
.miku-button--small {
  min-height: 24px !important;
  border-radius: 8px !important;
}

.miku-button--small::before {
  border-radius: 8px !important;
}

.miku-button--small::after {
  border-radius: 6px !important;
  top: 1.5px !important;
  left: 1.5px !important;
  right: 1.5px !important;
  bottom: 1.5px !important;
}

.miku-button--small .ant-btn {
  padding: 0px 12px !important;
  font-size: 12px !important;
  height: 24px !important;
  line-height: 22px !important;
  border-radius: 6px !important;
}

.miku-button--medium {
  min-height: 36px !important;
  border-radius: 10px !important;
}

.miku-button--medium::before {
  border-radius: 10px !important;
}

.miku-button--medium::after {
  border-radius: 8px !important;
  top: 2px !important;
  left: 2px !important;
  right: 2px !important;
  bottom: 2px !important;
}

.miku-button--medium .ant-btn {
  padding: 0px 20px !important;
  font-size: 14px !important;
  height: 36px !important;
  line-height: 34px !important;
  border-radius: 8px !important;
}

.miku-button--large {
  min-height: 48px !important;
  border-radius: 12px !important;
}

.miku-button--large::before {
  border-radius: 12px !important;
}

.miku-button--large::after {
  border-radius: 10px !important;
  top: 2px !important;
  left: 2px !important;
  right: 2px !important;
  bottom: 2px !important;
}

.miku-button--large .ant-btn {
  padding: 0px 28px !important;
  font-size: 16px !important;
  height: 48px !important;
  line-height: 46px !important;
  border-radius: 10px !important;
}

.miku-button-content {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 100%;
  width: 100%;
}

/* 图标尺寸适配 - 加大区分度 */
.miku-icon {
  transition: all 0.3s ease;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
  display: flex;
  align-items: center;
}

.miku-button--small .miku-icon {
  font-size: 10px !important;
  gap: 4px !important;
}

.miku-button--medium .miku-icon {
  font-size: 14px !important;
  gap: 6px !important;
}

.miku-button--large .miku-icon {
  font-size: 18px !important;
  gap: 8px !important;
}

.miku-button--glow .miku-icon {
  filter: drop-shadow(0 0 8px rgba(57, 197, 187, 0.8));
}

/* Loading 图标样式 */
.miku-loading-icon {
  animation: spin 1s linear infinite;
  display: flex;
  align-items: center;
}

.miku-button--small .miku-loading-icon {
  font-size: 10px !important;
}

.miku-button--medium .miku-loading-icon {
  font-size: 14px !important;
}

.miku-button--large .miku-loading-icon {
  font-size: 18px !important;
}

.miku-button--primary .miku-loading-icon {
  color: white !important;
}

.miku-button--secondary .miku-loading-icon {
  color: #39C5BB !important;
}

.miku-button--glow .miku-loading-icon {
  color: white !important;
  filter: drop-shadow(0 0 4px rgba(57, 197, 187, 0.8));
}

/* 文字样式 */
.miku-text {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 闪光效果 */
.miku-sparkle-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.sparkle {
  position: absolute;
  background: white;
  border-radius: 50%;
  opacity: 0;
  animation: sparkleFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 0 4px rgba(57, 197, 187, 0.8));
}

/* 不同尺寸的闪光大小 */
.miku-button--small .sparkle {
  width: 2px;
  height: 2px;
}

.miku-button--medium .sparkle {
  width: 3px;
  height: 3px;
}

.miku-button--large .sparkle {
  width: 4px;
  height: 4px;
}

.sparkle:nth-child(1) {
  top: 20%;
  left: 10%;
  animation-delay: 0s;
}

.sparkle:nth-child(2) {
  top: 60%;
  left: 80%;
  animation-delay: 0.7s;
}

.sparkle:nth-child(3) {
  top: 30%;
  left: 60%;
  animation-delay: 1.4s;
}

.sparkle:nth-child(4) {
  top: 80%;
  left: 30%;
  animation-delay: 2.1s;
}

/* 悬停效果 - 修复边框缺口 */
.miku-hover-effect {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(255, 255, 255, 0.2), 
    transparent);
  transition: left 0.6s ease;
  z-index: 2;
  /* 确保不破坏边框 */
  border-radius: inherit;
}

.miku-button:hover .miku-hover-effect {
  left: 100%;
}

.miku-button:hover .miku-icon {
  transform: scale(1.1) rotate(10deg);
}

.miku-button--primary:hover::after,
.miku-button--secondary:hover::after {
  filter: brightness(1.1);
}

.miku-button--glow:hover::after {
  background: linear-gradient(135deg, rgba(57, 197, 187, 0.4) 0%, rgba(0, 255, 255, 0.3) 100%);
}

.miku-button:hover .ant-btn {
  transform: translateY(-2px);
}

/* Loading 状态下的悬停效果 */
.miku-button--loading:hover .ant-btn {
  transform: none !important;
  cursor: not-allowed !important;
}

/* 激活状态 */
.miku-button:active .ant-btn {
  transform: translateY(0);
  transition: transform 0.1s ease;
}

.miku-button:active::after {
  filter: brightness(0.9);
}

/* Loading 状态特殊处理 */
.miku-button--loading {
  cursor: not-allowed !important;
}

.miku-button--loading::before {
  animation-duration: 1.5s !important;
}

.miku-button--loading .miku-button-content {
  opacity: 0.9;
}

/* 动画定义 */
@keyframes gradientShift {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes textGlow {
  0% {
    text-shadow: 0 0 10px rgba(57, 197, 187, 0.8);
  }
  100% {
    text-shadow: 0 0 20px rgba(57, 197, 187, 1), 0 0 30px rgba(0, 255, 255, 0.6);
  }
}

@keyframes sparkleFloat {
  0%, 100% {
    opacity: 0;
    transform: translateY(0) scale(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-15px) scale(1);
  }
}

/* 发光按钮的特殊动画 */
@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 20px var(--button-glow);
  }
  50% {
    box-shadow: 0 0 30px var(--button-glow), 0 0 40px var(--button-glow);
  }
}

.miku-button--glow {
  animation: glowPulse 2s ease-in-out infinite;
}

/* 禁用状态 */
.miku-button.ant-btn-disabled {
  opacity: 0.6;
  cursor: not-allowed;
  animation: none !important;
}

.miku-button.ant-btn-disabled::before {
  animation: none;
  background: #d9d9d9;
}

.miku-button.ant-btn-disabled::after {
  background: #f5f5f5;
}

.miku-button.ant-btn-disabled .ant-btn {
  color: #bfbfbf;
  text-shadow: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .miku-button--small .ant-btn {
    padding: 0px 10px !important;
    font-size: 11px !important;
    height: 22px !important;
    line-height: 20px !important;
  }
  
  .miku-button--medium .ant-btn {
    padding: 0px 16px !important;
    font-size: 13px !important;
    height: 32px !important;
    line-height: 30px !important;
  }
  
  .miku-button--large .ant-btn {
    padding: 0px 22px !important;
    font-size: 14px !important;
    height: 40px !important;
    line-height: 38px !important;
  }
}

/* 确保 Ant Design 默认样式不干扰 */
.miku-button.ant-btn {
  line-height: 1.5715;
  position: relative;
  display: inline-block;
  font-weight: 400;
  white-space: nowrap;
  text-align: center;
  background-image: none;
  box-shadow: none;
}

.miku-button.ant-btn:focus {
  outline: none;
}

/* 修复按钮内容对齐 */
.miku-button .ant-btn > span {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 100% !important;
  width: 100% !important;
}

/* 确保所有状态下的边框完整性 */
.miku-button * {
  box-sizing: border-box;
}